/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */
package org.jeecg.modules.third.jg.report.information.constant.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 天津省平台上报单据类型
 *
 * @author duanlikao
 * @created 2020/12/31
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum ReportDocTypeEnum {

    REPORT_DOC_TYPE_WLHY_JSY("WLHY_JSY1001", "驾驶员信息"),
    REPORT_DOC_TYPE_WLHY_QY("WLHY_QY1001", "企业信息"),
    REPORT_DOC_TYPE_WLHY_ZJ("WLHY_JZ1001", "资金流水单"),
    REPORT_DOC_TYPE_WLHY_YD("WLHY_YD1001", "电子运单"),
    REPORT_DOC_TYPE_WLHY_CL("WLHY_CL1001", "车辆基本信息"),
    REPORT_DOC_TYPE_WLHY_WZCX("WLHY_WZCX1001", "驾驶员位置信息"),
    ;

    private  String code;
    private  String msg;

    private static Map <String, ReportDocTypeEnum> codeMap = Maps.newHashMap();

    public String getCode() {
        return this.code;
    }

    public String getDesc() {
        return this.msg;
    }

    public static String getMsg(String code) {
        return codeMap.containsKey(code) ? codeMap.get(code).getDesc() : StringUtils.EMPTY;
    }

    public static boolean isValid(String code) {
        return codeMap.containsKey(code);
    }

    static {
        for (ReportDocTypeEnum status : ReportDocTypeEnum
                .values()) {
            codeMap.put(status.getCode(), status);
        }
    }

    public static ReportDocTypeEnum getReportDocTypeEnumByVal(String code) {
        return Arrays.stream(ReportDocTypeEnum.values())
                .collect(Collectors.toMap(
                        ReportDocTypeEnum::getCode, value -> value, (k1, k2) -> k2)).get(code);
    }
}